import { WeElement, define } from 'omi';
import './index.css'

define('my-picker', class extends WeElement {
  data={}

  change_choose=(e)=>{
    this.fire('changechecked',e.currentTarget.dataset.index)
  }
  close_picker=(e)=>{
    this.fire('closepicker',false)
  }


  render(){
    return (
        <view class='my_picker'>
          <view class='mask' catchtap={this.close_picker}></view>
          <view class='picker_box'>
            <view class='picker_title'>{this.props.picked.title}</view>
            {
              this.props.picked.content.map((item, index) => {
                return (
                  <view class='picker_item' catchtap={this.change_choose} data-index={index} key={index}>
                    <view class='picker_text'>{item}</view>
                    <view class={index == this.props.picked.choose ? 'active' : 'picker_point'} ></view>
                  </view>
                )
              })
            }
            <view class='close_btn' catchtap={this.close_picker}>关闭</view>
          </view>
        </view>
    )
  }
})